package cn.tedu.overhaul.management.dto.persist.repository.impl;

import cn.tedu.overhaul.management.dto.persist.mapper.OverhaulMapper;
import cn.tedu.overhaul.management.dto.persist.mapper.OverhaulRentMapper;
import cn.tedu.overhaul.management.dto.persist.mapper.OverhaulToolMapper;
import cn.tedu.overhaul.management.dto.persist.repository.IOverhaulRentRepository;
import cn.tedu.overhaul.management.dto.persist.repository.IOverhaulRepository;
import cn.tedu.overhaul.management.dto.persist.repository.IOverhaulToolRepository;
import cn.tedu.overhaul.management.pojo.dto.OverhaulRentUpdateAllDTO;
import cn.tedu.overhaul.management.pojo.dto.ToolAddNewDTO;
import cn.tedu.overhaul.management.pojo.dto.ToolAllDTO;
import cn.tedu.overhaul.management.pojo.entity.OverhaulRent;
import cn.tedu.overhaul.management.pojo.vo.*;
import cn.tedu.rtms.commons.pojo.vo.PageData;
import cn.tedu.rtms.commons.util.PageInfoToPageDataConverter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.tools.Tool;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Repository
public class OverhaulToolRepositoryImpl implements IOverhaulToolRepository {
    @Autowired
    OverhaulToolMapper overhaulToolMapper;





    @Override
    public PageData<ToolVO> selectRent(Integer pageNum, Integer pageSize) {
        log.debug("开始执行【查询工具列表】的数据访问，页码：{}，每页记录数：{}", pageNum, pageSize);
        PageHelper.startPage(pageNum, pageSize);
        List<ToolVO> listOriginal=overhaulToolMapper.selectRent();
        log.debug("listOriginal={}",listOriginal);
        PageInfo<ToolVO> pageInfo = new PageInfo<>(listOriginal);
        PageData<ToolVO> pageData = PageInfoToPageDataConverter.convert(pageInfo);
        log.debug("pageData={}",pageData);
        return pageData;
    }

    @Override
    public List<String> selectByToolNumber() {
        return overhaulToolMapper.selectByToolNumber();
    }

    @Override
    public int insertTool(ToolAddNewDTO toolAddNewDTO) {
        return overhaulToolMapper.insertTool(toolAddNewDTO);
    }

    @Override
    public ToolAllVO getStandardByIdAll(Long id) {
        ToolAllVO toolAllVO= overhaulToolMapper.getStandardByIdAll(id);
        return toolAllVO;
    }

    @Override
    public int update(ToolAllDTO toolAllDTO) {
        return overhaulToolMapper.update(toolAllDTO);
    }
}
